package cn.blunce.utils.XmlParse;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import cn.blunce.mylib.R;

public class XstreamTestActivity extends Activity {

    private TextView showContent;
    private Person person;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xstream_test);

        showContent = (TextView) findViewById(R.id.show_content_in_xstream_test);

        showXmlTest();
//        showJsonTest();
    }


    private void showXmlTest() {
        person = new Person();
        person.setId(12);
        person.setName("test");
        person.setAge(Short.valueOf("24"));

        showContent.setText(person.toString());
        showContent.append("\n\n");
        String tmp = XstreamParse.toXml(person);
        showContent.append(tmp);
        showContent.append("\n\n");
        showContent.append(XstreamParse.toPerson(tmp).toString());
        showContent.append("\n\n");
        tmp = XstreamParse.toXmlPro(person);
        showContent.append(tmp);
        showContent.append("\n\n");
        showContent.append(XstreamParse.toPersonPro(tmp).toString());
        showContent.append("\n\n");
    }

    private void showJsonTest() {
        String tmp = XstreamParse.PersonToJson(person);
        showContent.append(tmp);
        showContent.append("\n\n");
        showContent.append(XstreamParse.JsonToPerson(tmp).toString());
    }
}
